<?php
header("content-type:text/html;charset=utf-8");

session_start();

if(isset($_SESSION["name"]))

{

require("connu.inc.php");

$selectrec = "SELECT count(whether) FROM userinfo WHERE whether=1";

$resultrec = mysql_query($selectrec);

while($rec = mysql_fetch_row($resultrec))
{
	foreach($rec as $data)
	{
		$recive = $data;
	}
}



$selectnum = "SELECT count(name) FROM userinfo ";

$resultnum = mysql_query($selectnum);

while($num = mysql_fetch_row($resultnum))
{
	foreach($num as $data2)
	{
		$number = $data2;
	}
}
$norecive = $number-$recive;

$totalnum=$number;
//每页显示条数
$pagesize=20;
//总共有几页
$maxpage=ceil($totalnum/$pagesize);
$page=isset($_GET['page'])?$_GET['page']:1;
if($page <1)
{
$page=1;
}
if($page>$maxpage)
{
$page=$maxpage;
}
$limit=" limit ".($page-1)*$pagesize.",$pagesize";
$sql1="select * from userinfo {$limit}";
  

$res=mysql_query($sql1);

?>





<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>领取信息</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Bootstrap -->
    <link rel="stylesheet" href="http://cdn.bootcss.com/twitter-bootstrap/3.0.3/css/bootstrap.min.css">
	<link rel="stylesheet" href="blogsystemcss.css">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="http://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.min.js"></script>
        <script src="http://cdn.bootcss.com/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
	  <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="http://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="http://cdn.bootcss.com/twitter-bootstrap/3.0.3/js/bootstrap.min.js"></script>
	<style>
		.page-header
		{
		margin-top:0;
		background:#B0E0E6;
		}
		.col-1
		{
		background:#D6D6D6;
		}
		.td1
		{
		margin-top:30px;
		margin-bottom:80px;
		}
		h5
		{
		margin-bottom:0;
		}
	</style>
	</head>
  <body>
	<div class="container">
		<nav class="navbar navbar-default page-header">
			<!-- Brand and toggle get grouped for better mobile display -->
				<div class="navbar-header">
					<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
						<span class="sr-only">Toggle navigation</span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
					</button>
					<a class="navbar-brand" href="#"><b>大乐透代金券中奖查询</b></a>
				</div>

				<!-- Collect the nav links, forms, and other content for toggling -->
				<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">				
					<ul class="nav navbar-nav navbar-right">
						<li><a href="login.html">退出</a></li>
					</ul>
				</div><!-- /.navbar-collapse -->
		</nav>
		<div class="row">
			<div class="col-md-2 col-sm-3">
				<nav class="navbar navbar-default col-1" id="sidebar-wrapper" role="navigation">
					<ul class="nav sidebar-nav">
						<li class="sidebar-brand"> <a href="info.php"><p align="center">领取信息</p></a> </li>
						<li> <a href="uploadexcel.html"><p align="center">上传文件</p></a> </li>
					</ul>
				</nav>
			</div>
			<div class="col-md-10 col-sm-9">
				<div>
					<p>总人数：<?php echo $number?></p>
					<p>已领取：<?php echo $recive?> / 未领取：<?php echo $norecive?><p>
				</div>
				<table  class="table table-striped table-condensed">
				<tr>
					<th>id</th>
					<th>姓名</th>
					<th>电话</th>
					<th>中奖期数</th>
					<th>领取记录</th>
					<th>领取时间</th>
					<th>领取站点</th>
				</tr>
				<?php
					while($row = mysql_fetch_array($res))
					{
				?>
				<tr>
					<td><?php echo $row["id"]?></td>
					<td><?php echo $row["name"]?></a></td>
					<td><?php echo $row['tel']?></td>
					<td><?php echo $row["winnum"]?></td>
					<td><?php $w=$row["whether"];
							  if($w==1)
								  echo '<font style="color:#32CD32;">已领取</font>';
							  if($w==NULL)
								  echo '<font style="color:#CD0000;">未领取</font>';
					?></td>
					<td><?php if($row["recivetime"]!=NULL){echo date("Y-m-d H:i",$row["recivetime"]);}else{echo '&nbsp;';}?></td>
					<td><?php echo $row["site"]?></td>
				<?php
					}
					?>	
				</tr>
				</table>
			</div>
		</div>
		<div class="td1" align="center">
		<td colspan="6">
		<?php
			echo " 当前{$page}/{$maxpage}页 共{$totalnum}条";
			echo " <a href='info.php?page=1'>首页</a> ";
			echo "<a href='info.php?page=".($page-1)."'>上一页</a>";
			echo "<a href='info.php?page=".($page+1)."'>下一页</a>";
			echo " <a href='info.php?page={$maxpage}'>尾页</a> ";
		
		?>
		</td>
		</div>
	</div>

	<h5 align="center">技术支持 舜网（<a href="http://www.e23.cn">www.e23.cn</a>）
	</h5>



	<script>
		
	</script>
  </body>
</html>
<?php
}
else
{
	echo '<script>alert("请先登录");location.href="login.php";</script>';
}
?>